// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

/*

Tracks: Revision: 470b039c7fd0, Russ Cox, Date:	Sep 12, 2011

*/

package main

type def struct {
	src []string
	msg string
}

var defs = []def{
	//% loadsys package LIMPORT '(' LLITERAL import_package import_there ','
	//"unexpected comma during import block",
	{[]string{
		`
import (
	"io",
	"os"
)
`,
		`
import (
	"io"
	"os",
	"foo"
)
`},
		"unexpected comma during import block"},

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LIF if_header ';'
	//"unexpected semicolon or newline before {",
	{[]string{
		`
func main() {
	if x; y
	{
		z


`,
		`
func main() {
	{
		if x; y
		{
			z



`},
		"unexpected semicolon or newline before {"},

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LSWITCH if_header ';'
	//"unexpected semicolon or newline before {",
	{[]string{
		`
func main() {
	switch x; y
	{
		z


`,
		`
func main() {
	{
		switch x; y
		{
			z


`},
		"unexpected semicolon or newline before {"},

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR for_header ';'
	//"unexpected semicolon or newline before {",
	{[]string{
		`
func main() {
	for x; y; z
	{
		z


`,
		`
func main() {
	{
		for x; y; z
		{
			z


`},
		"unexpected semicolon or newline before {"},

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR ';' LBODY
	//"unexpected semicolon or newline before {",
	{[]string{
		`
func main() {
	for x
	{
		z


`,
		`
func main() {
	{
		for x
		{
			z


`},
		"unexpected semicolon or newline before {"},

	//% loadsys package imports LFUNC LNAME '(' ')' ';' '{'
	//"unexpected semicolon or newline before {",
	{[]string{
		`
func main()
{



`},
		"unexpected semicolon or newline before {"},

	//% loadsys package imports LTYPE LNAME ';'
	//"unexpected semicolon or newline in type declaration",
	{[]string{
		`
type T
{



`,
		`
func f() {
	type T
	{



`},
		"unexpected semicolon or newline in type declaration"},

	//% loadsys package imports LCHAN '}'
	//"unexpected } in channel type",
	{[]string{
		`
type xyz struct {
    ch chan
}`,
		`
type xyz chan}
`},
		"unexpected } in channel type"},

	//% loadsys package imports LCHAN ')'
	//"unexpected ) in channel type",
	{[]string{
		`
func Foo(y chan) {
}
`,
		`
type xyz chan)
`},
		"unexpected ) in channel type"},

	//% loadsys package imports LCHAN ','
	//"unexpected comma in channel type",
	{[]string{
		`
func Bar(x chan, y int) {}
`,
		`
type xyz chan,
`},
		"unexpected comma in channel type"},

	//% loadsys package imports LFUNC LNAME '(' ')' '{' if_stmt ';' LELSE
	//"unexpected semicolon or newline before else",
	{[]string{
		`
func main() {
	if x { }
	else { }
}


`,
		`
func main() {
	{
		if x { }
		else { }
	}
}


`},
		"unexpected semicolon or newline before else"},

	//% loadsys package imports LTYPE LNAME LINTERFACE '{' LNAME ',' LNAME
	//"name list not allowed in interface type",
	{[]string{
		`
type T interface {
	f, g ()
}
`,
		`
type T struct {
	f interface{
		g, h()
	}
}
`},
		"name list not allowed in interface type"},

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LFOR LVAR LNAME '=' LNAME
	//"var declaration not allowed in for initializer",
	// in parser.y: node_for_header

	//% loadsys package imports LVAR LNAME '[' ']' LNAME '{'
	//"unexpected { at end of statement",
	{[]string{
		`
var x map[string]string{"a":"b"}


`,
		`
var x t[]{1}


`},
		"unexpected { at end of statement(1)"}, //TODO -(1)

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LVAR LNAME '[' ']' LNAME '{'
	//"unexpected { at end of statement",
	{[]string{
		`
func main() {
	var x map[string]string{"a":"b"}


`,
		`
func main() {
	var x t[]{1}


`},
		"unexpected { at end of statement(2)"}, //TODO -(2)

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LDEFER LNAME ';'
	//"argument to go/defer must be function call",

	//% loadsys package imports LVAR LNAME '=' LNAME '{' LNAME ';'
	//"need trailing comma before newline in composite literal",

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LFUNC LNAME
	//"nested func not allowed",

	//% loadsys package imports LFUNC LNAME '(' ')' '{' LIF if_header loop_body LELSE ';'
	//"else must be followed by if or statement block"
	{[]string{
		`
func main() {
	if true {
	} else ;
}
`,
		`
func main() {
	func() {
		if x() {
		} else ;
	}()
}
`,
		`
func main() {
	if true {
	} else f()
}
`},
		"else must be followed by if or statement block"},
}
